package org.liulinlin.sejw.db;

import java.sql.*;

public class ShipSchedule { //extends DataAccessServiceImpl {
	private String id;
	private String route;
	private ShipInfo shipInfo;
	private String starter;
	private String destination;
	private String stopOver;
	private java.sql.Date leaveTime;
	private String leaveTimeString;
	private java.sql.Date arriveTime;
	private String arriveTimeString;
	private String comments;
	
	public ShipSchedule() {
		
	}
	public ShipSchedule(String id) {
		DBConnectionManager connMgr = DBConnectionManager.getInstance();
		
		Connection con = connMgr.getConnection("shipping_export");
		if (con == null) {
			System.out.println("不能获得数据库连接");
			return;
		}
		Statement stmt = null;
		ResultSet rs = null;
		
		try {
			stmt = con.createStatement();
			rs = stmt.executeQuery("select * from ShipSchedule where Scd_ID = '" + id + "'");
		
			rs.next();
			this.id = id;
			route = rs.getString("Scd_Route");
			shipInfo = new ShipInfo(rs.getString("Ship_ID"));
			starter = rs.getString("Scd_Starter");
			destination = rs.getString("Scd_Destination");
			stopOver = rs.getString("Scd_Stopover");
			leaveTime = rs.getDate("Scd_LeaveTime");
			leaveTimeString = leaveTime.toString();
			arriveTime = rs.getDate("Scd_ArriveTime");
			arriveTimeString = arriveTime.toString();
			comments = rs.getString("Scd_Comments");
			
			stmt.close();
			rs.close();
		} catch(SQLException e) {
			e.printStackTrace();
		}
		
		connMgr.freeConnection("shipping_export", con);
		connMgr.release();
	}
	
	public void setId(String id) {
		this.id = id;
	}
	public void setRoute(String route) {
		this.route = route;
	}
	public void setShipInfo(ShipInfo shipInfo) {
		this.shipInfo = shipInfo;
	}
	public void setStarter(String starter) {
		this.starter = starter;
	}
	public void setDestination(String destination) {
		this.destination = destination;
	}
	public void setStopOver(String stopOver) {
		this.stopOver = stopOver;
	}
	public void setLeaveTime(java.sql.Date leaveTime) {
		this.leaveTime = leaveTime;
	}
	public void setLeaveTimeString(String leaveTimeString) {
		this.leaveTimeString = leaveTimeString;
	}
	public void setArriveTime(java.sql.Date arriveTime) {
		this.arriveTime = arriveTime;
	}
	public void setArriveTimeString(String arriveTimeString) {
		this.arriveTimeString = arriveTimeString;
	}
	public void setComments(String comments) {
		this.comments = comments;
	}
	
	public String getId() {
		return id;
	}
	public String getRoute() {
		return route;
	}
	public ShipInfo getShipInfo() {
		return shipInfo;
	}
	public String getStarter() {
		return starter;
	}
	public String getDestination() {
		return destination;
	}
	public String getStopOver() {
		return stopOver;
	}
	public java.sql.Date getLeaveTime() {
		return leaveTime;
	}
	public String getLeaveTimeString() {
		return leaveTimeString;
	}
	public java.sql.Date getArriveTime() {
		return arriveTime;
	}
	public String getArriveTimeString() {
		return arriveTimeString;
	}
	public String getComments() {
		return comments;
	}
}
